package com.ftg.learn.bus.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ftg.learn.bus.entity.Log;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 操作记录表 Mapper 接口
 * </p>
 *
 * @author lalala
 * @since 2022-03-07
 */
public interface LogMapper extends BaseMapper<Log> {

    /**
     * 添加日志
     */
    @Insert("INSERT into sys_log (lname,operations,nameid,operator,operation_date) VALUES (#{lname}," +
            "#{operations},#{nameid},#{operator},now())")
    void addLog(String lname, String operations,Long nameid,String operator);


    /**
     * 模糊查询
     * @param lname 操作名称
     * @return
     */
    @Select("select * from sys_log where lname like CONCAT('%',#{lname},'%')")
    List<Log> showLog(@Param("lname") String lname, Page<Log> page);

}
